/**
 * 动画工具类
 */
export default class Animation {
  /**
   * 创建动画
   * @param {Function} callback - 动画回调函数
   * @param {number} duration - 动画持续时间（毫秒）
   * @param {Function} [easing] - 缓动函数
   */
  static animate(callback, duration, easing = t => t) {
      const startTime = performance.now();
      
      const tick = (currentTime) => {
          const elapsed = currentTime - startTime;
          const progress = Math.min(elapsed / duration, 1);
          
          callback(easing(progress));
          
          if (progress < 1) {
              requestAnimationFrame(tick);
          }
      };
      
      requestAnimationFrame(tick);
  }

  /**
   * 创建脉冲动画效果
   * @param {number} time - 当前时间
   * @param {number} [frequency=5] - 频率
   * @returns {number} 脉冲值 (0-1)
   */
  static pulse(time, frequency = 5) {
      return Math.sin(time * frequency) * 0.5 + 0.5;
  }
}